package com.dd.controller;


import com.dd.pojo.Vip;
import com.dd.pojo.Yuyue;
import com.dd.service.YuyueService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/yuyue")
public class YuyueController {
    @Autowired
    YuyueService yuyueService;

    @RequestMapping("/findbyuname")
    public String findbyuname(String uname) throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper();
        List<Yuyue> list = yuyueService.findbyuname(uname);
        String str = mapper.writeValueAsString(list);
        String jso = "{\"code\":0,\"msg\":\"\",\"count\":" + 25 + ",\"data\":" + str + "}";
        return jso;
    }

    @RequestMapping("/addyuyue")
    public String addyuyue(Yuyue yuyue){
        yuyueService.addyuyue(yuyue);
        return "1";
    }

    @RequestMapping("/deletebyid")
    public String deletebyid(int id){
        yuyueService.deletebyid(id);
        return "1";
    }

}
